﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WsdShop.Model;
using WsdShop.Model.SearchModels;
using WsdShop.Model.ViewModels;

namespace WsdShop.IService
{
    public interface IOrderService
    {
        bool EditOrderDetail(OrderDetail model);

        bool EditOrder(Order model);

        List<V_Order> GetOrderManage(OrderManageSearchModel search, ref int total);

        List<V_Order> GetPointOrderManage(OrderManageSearchModel search, ref int total);
        /// <summary>
        /// 我的订单列表
        /// </summary>
        /// <param name="memberId"></param>
        /// <returns></returns>
        List<V_Order> GetMyOrderList(int memberId);
        List<OrderDetail> GetOrderDetailByOrderId(int orderId);
        Order GetOrderInfo(int id);
        V_Order GetOrderModel(int id);


        Order GetOrderInfo(string orderNo);

        int AddOrder(Order order, List<OrderDetail> productList, OrderRecord or);
        bool UpdateOrder(Order order);


        /// <summary>
        /// 订单确认支付
        /// </summary>
        /// <param name="orderNo">订单号</param>
        /// <param name="operationUserType">操作用户类型0会员 1后台用户</param>
        /// <param name="userId">操作用户Id</param>
        void PayOrder(string orderNo, OrderRecord or);

        /// <summary>
        /// 生成订单号
        /// </summary>
        /// <param name="key">W:正常订单，T:团购订单，P:积分订单，X:限时抢购订单，Y:一分钱活动订单</param>
        /// <returns></returns>
        string GetSerialNumber(string key);

        void AddOrderRecord(OrderRecord model);
        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="orderId">订单Id</param>
        /// <param name="or">订单操作记录</param>
        void DelOrder(int orderId, OrderRecord or);
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="orderId">订单Id</param>
        /// <param name="or">订单操作记录</param>
        void CancelOrder(int orderId, OrderRecord or);
        /// <summary>
        /// 确认订单
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="or"></param>
        void ConfirmOrder(int orderId, OrderRecord or);

        /// <summary>
        /// 订单操作记录
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        List<V_OrderRecord> GetOrderRecord(int orderId);

        /// <summary>
        /// 分页获取发货订单
        /// </summary>
        /// <param name="search"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        List<V_Order> GetSendOrderList(OrderManageSearchModel search, ref int total);

        List<V_Delivery> GetDeliveryListByOrderId(int orderId);

        void AddDelivery(Delivery model, int[] ids);

        int GetMemberSpikeCount(int memberId, int productId);

        #region 积分订单
        List<V_Order> GetMyPointOrderList(int memberId);
        #endregion

        /// <summary>
        /// 获取我的降拼订单
        /// </summary>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <param name="memberId"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        IEnumerable<V_Order> GetGroupOrderList(int skip, int take, int memberId, ref int total);

        #region 退货
        int AddReturnGoods(ReturnGoods model);

        List<V_ReturnGoods> GetReturnGoodsManage(ReturnGoodsSearchModel search, ref int total);

        List<V_ReturnGoods> GetMyReturnGoodsList(int memberId);

        V_ReturnGoods FindReturnGoods(int id);

        ReturnGoods GetReturnGoodsInfo(int id);

        bool EditReturnGoods(ReturnGoods model);

        void ConfirmReturnGoods(ReturnGoods model, ref decimal rmoney, ref decimal pmoney, ref decimal mmoney);

        int DaiReturnGoodsCount();

        int DoingReturnGoodsCount();
        #endregion


        /// <summary>
        /// 一分钱活动抽奖
        /// </summary>
        /// <param name="actId"></param>
        /// <param name="tId"></param>
        /// <param name="prize"></param>
        /// <param name="member"></param>
        /// <param name="teammember"></param>
        /// <returns></returns>
        bool YiFenDraw(int actId, Member member, V_ActivityTeamMembers teammember, ref DrawReward prize);

        List<V_OrderDetail> GetV_OrderDetailByOrderId(int orderId);

        OrderDetail FindOrderDetail(int id);


        /// <summary>
        /// 统计累计销售金额
        /// </summary>
        /// <returns></returns>
        decimal GetSaleMoney();


        /// <summary>
        /// 统计待发货的订单
        /// </summary>
        /// <returns></returns>
        int GetShipmentPending();

        /// <summary>
        /// 收货
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int GoodsReceipt(int id, int memberid);

        int Getdaipingjia();

        int Getyipingjia();
    }
}
